﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HelloMinasan.Business;
using HelloMinasan.Caching;
using HelloMinasan.Caching.CacheObjects;
using HelloMinasan.Cdn;
using HelloMinasan.Domain;
using HelloMinasan.Domain.Dtos;
using HelloMinasan.UserDefinedType;
using HelloMinasan.Resources;

namespace HelloMinasan.Web.ViewModels
{
    public class HeaderModel
    {
        //TODO: maybe we'll delete this properties. and use Action render for combobox list to cache it.
        static private IList<DictionarySupport> _Dictionaries;

        public HeaderModel()
        {
            //Dictionary = EnumDictionary.en_vi; //TODO: vay ma tai sao no van default la en_en?
            //TopTab = EnumTopTab.Home;
            CurrentDictionary = EnumDictionary.None;
            CurrentWord = "";
        }

        public IList<DictionarySupport> CreateListDictionary()
        {
            if (_Dictionaries == null || _Dictionaries.Count == 0)
            {
                var vocabularyService = DependencyResolver.Current.GetService<IVocabularyService>();
                _Dictionaries = vocabularyService.GetDictionarySupportList();
                return _Dictionaries;
            }
            else
            {
                return _Dictionaries;
            }
        }

        public void SetDictionaryHeader(EnumTopTab topTab, EnumDictionary currentDictionary)
        {
            TopTab = topTab;
            CurrentDictionary = currentDictionary;
        }

        public void SetHomeHeader()
        {

        }

        public EnumTopTab TopTab { get; set; }

        //common properties for all mode
        public string SearchingText { get; set; }

        //properties for pronunciation mode
        public EnumDictionary CurrentDictionary { get; set; }
        public IList<DictionarySupport> Dictionaries
        {
            get
            {
                if (_Dictionaries == null)
                    return CreateListDictionary();
                return _Dictionaries;
            }
            set
            {
                _Dictionaries = value;
            }
        }

        public string CurrentWord { get; set; }

        //TODO: properties for quote mode
        //to be defined

        //TODO: properties for song mode
        //to be defined
    }
}